q()
ls
sasdfdjfk
sasdfdjfk
x <- c(1,2)
x
x[1]
x[1] + x[2]
_
T
F
True
TRUE
class(x[1])
class(x)
x
class(T)
t <-class(T)
t
class(t)
for
e
sum(x)
summary(x)
length(x)
x+1
x+(2)
x+(1,2)
x+c(3,1)
exp(x)
l <-list(1,'a')
l
l
data.frame(x, l)
ll <- list(name='전철욱)
ㅊ
c
dfa
;
/
1
ll <- list(name='전철욱')
ll
ll.name
ll.$name
ll.$name
ll
ll$name
example('mean')
c(1:5)
c(1:5::2)
c(1::5)
c(1:15)
c(1:15,1)
xx <- c(1:10)
sum(xx)
example(sum)
example(sum)
example('sum')
example('sum'get)
getwd()
installed.packages
installed.packages()
function(d, 2)
i <- 0
i
print(i)
whie(i<10)
whie(i<10){i<-i+1; print(i)}
whie(i<10){i<-i+1; print(i)}
whie(i<10) {i<-i+1; print(i)}
r <- c(1:10)
for(i in r) {print(i)}
if(i>100) {print('s')}
if(i>100) {print('s')}
i
i<1011
i<-1011
if(i>100) {print('s')}
dist <-function(a,b) {a+b}
a <-c(1:10)
b <-c(1:10)
dist(a,b)
numeric(2)
numeric(10)
a = numeric(2)
b = numeric(2)
a+b
a
b
b
heads <- rbinom(10^5, 100,0,50)
ls
ls()
heads <- rbinom(10^5, 100,0.50)
heads
data(iris)
length(iris$Sepal.Length)
iris$Species
factor(iris$Species)
unique(iris$Species)
s.q = _
s.q = unique(iris$Species)
s.q
s
s.q
data.class(iris)
class(iris)
fix(s.q)
View(iris)
x<-rnorm(100,sd=2)
x
y<-0.3+2*x+rnorm(100,sd=1)
y
plot(x)
pie.sales <- c(0.12,0.3, 0.26, .16, .04, .12)
pie.sales
names(pie.sales)
names(pie.sales)<-c('b','c','a','bo','o','v')
names(pie.sales)
barplot(pie.sales)
pie(pie.sales)
sum(pie.sales)
attach
attach(faithful)
l <- c(1,2,3)
l
l[1]
l[[1]]
c(1::3)
(1::3)
c(1:3)
l = c(1,'a')
l
c[1]
l[1]
matrix(1:6,2,3)
s = c('y', 'n', 'y')
sf = factor(s)
sf
sf$lavels
fix(sf)
sf$label
sf
is.na(sf)
~is.na(sf)
is.na(sf)
fix(l)
l
args(rnorm)
rnorm(1,2)
rnorm(10,2)
rnorm(10,2,1)
rbinom(10,size-10,prob-0.5)
rbinom(10,size-10,prob-0.5)
source('~/.active-rstudio-document')
x = seq(0,10, by=1)
x
x = seq(0,10, by=2)
x
dbinom(10, size-10, prob=0.5)
dbinom
dbinom(x, size-10, prob=0.5)
dbinom(x, size=10, prob=0.5)
dbinom(10, size=10, prob=0.5)
dbinom(1, size=10, prob=0.5)
x = seq(0,10, by=1)
dbinom(x, size=10, prob=0.5)
round(dbinom(x, size=10, prob=0.5),2)
set.seed(31);
heightsCM = rnorm(30,mean=188, sd=5);
weightsK = rnorm(30,mean=84,sd=3);
hasDaughter = sample(c(TRUE,FALSE),size=30,replace=T);
dataFrame = data.frame(heightsCM,weightsK,hasDaughter);
mean(dataFrameSubset$weightsK)
mean(dataFrame$weightsK)
dataFrame$heightsCM<199
dataFrame
dataFrame$heightsCM<188
dataFrame(dataFrame$heightsCM<188)
dataFrame[(]dataFrame$heightsCM<188]
dataFrame[dataFrame$heightsCM<188]
dataFrame$heightsCM[dataFrame$heightsCM<188]
dataFrame$weightsK[dataFrame$heightsCM<188]
mean(dataFrame$weightsK[dataFrame$heightsCM<188])
sample(cauchyValues,10)
source('~/.active-rstudio-document')
s = sample(cauchyValues,10)
fix(s)
s
s = sample(cauchyValues,size=10)
s
s = sample(cauchyValues,size=10)
s
s = sample(cauchyValues,size=10)
s
dataFrame$weightsK[dataFrame$heightsCM>188]
mean(dataFrame$weightsK[dataFrame$heightsCM>188])
s = sample(cauchyValues,size=10s)
x <- seq(0,30,length=300)
x
x
hx <- dgamma(x, shape=1, scale=1)
hx
gshape <- c(2,5,10,15)
gshape
colors <- c('red','blue','darkgreen','gold')
plot(x, hx, type='n',lty=2,lwd=2,xlab='x')
for (i in 1:4){
lines(x, dgamma(x,shape=gshape[i], scale=1), lwd=2, col=colors[i])
} - See more at: http://www.stattler.com/article/how-do-graph-using-r#sthash.BxBEjhQA.dpuf
for (i in 1:4){
lines(x, dgamma(x,shape=gshape[i], scale=1), lwd=2, col=colors[i])
}
asd
asdf
plot(x, hx, type='n',lty=2,lwd=2,xlab='x')
plot(x, hx, type='n',lty=2, lwd=2)
dose<-c(20,30,40,45,60)
drugA<-c(16,20,25,31,40)
plot(dose,drugA,type='b')
plot(dose,drugA,type='c')
plot(dose,drugA,type='a')
plot(dose,drugA,type='d')
plot(dose,drugA,type='b')
Sys.Date()
date()
d<-date()
d
load("/media/sda3/data/study/brenden17.bitbucket.org/source/Machine Learning with R/chapter 2/2148_02.r")
library("gmodels", lib.loc="/home/brenden/R/x86_64-pc-linux-gnu-library/2.14")
detach("package:gmodels", unload=TRUE)
install.packages("arules")
R
version()\
version
vesion
vesion()
version
eixt
exit
q()
install.packages("astsa")
require(astsa)
data(jj)
jj
getwd
library(tm)
install.packages("tm")
install.packages("tm")
install.packages("RWeka")
install.packages("rJava")
sms_raw <- read.csv("sms_spam.csv", stringsAsFactors = FALSE)
# sms 데이터 구조
str(sms_raw)
# 팩터로 spam/ham으로 변환
sms_raw$type <- factor(sms_raw$type)
install.packages("tm")
install.packages("RWeka")
install.packages("rJava")
setwd("/media/sda3/data/study/brenden17.bitbucket.org/source/mlr-ko/chapter 4")
sms_raw <- read.csv("sms_spam.csv", stringsAsFactors = FALSE)
# sms 데이터 구조
str(sms_raw)
# 팩터로 spam/ham으로 변환
sms_raw$type <- factor(sms_raw$type)
# 변수형 확인
str(sms_raw$type)
table(sms_raw$type)
# 텍스트 마이닝(tm) 패키지를 사용하여 말뭉치 생성
library(tm)
sms_corpus <- Corpus(VectorSource(sms_raw$text))
# sms 말뭉치 확인
print(sms_corpus)
inspect(sms_corpus[1:3])
# tm_map() 사용하여 말뭉치 정리
corpus_clean <- tm_map(sms_corpus, tolower)
corpus_clean <- tm_map(corpus_clean, removeNumbers)
corpus_clean <- tm_map(corpus_clean, removeWords, stopwords())
corpus_clean <- tm_map(corpus_clean, removePunctuation)
corpus_clean <- tm_map(corpus_clean, stripWhitespace)
# 말뭉치 정리 확인
inspect(sms_corpus[1:3])
inspect(corpus_clean[1:3])
# 문서-용어 희소 매트릭스 생성
sms_dtm <- DocumentTermMatrix(corpus_clean)
sms_dtm <- DocumentTermMatrix(corpus_clean)
sms_dtm
sms_dtm <- DocumentTermMatrix(corpus_clean)
sms_raw_train <- sms_raw[1:4169, ]
sms_raw_test  <- sms_raw[4170:5559, ]
sms_dtm_train <- sms_dtm[1:4169, ]
sms_dtm_test  <- sms_dtm[4170:5559, ]
sms_corpus_train <- corpus_clean[1:4169]
sms_corpus_test  <- corpus_clean[4170:5559]
# 스팸 비율 확인
prop.table(table(sms_raw_train$type))
prop.table(table(sms_raw_test$type))
# 단어 클라우드 시각화
library(wordcloud)
# 말뭉치 정리 확인
inspect(sms_corpus[1:3])
inspect(corpus_clean[1:3])
# 문서-용어 희소 매트릭스 생성
sms_dtm <- DocumentTermMatrix(corpus_clean)
sms_dtm
fix(corpus_clean)
